home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 28
/
028.d81
/
t.magic lantern
< prev
next >
Wrap
Text File
|
2022-08-26
|
4KB
|
240 lines
MAGIC LANTERN
by
Bruce Jaeger
COMMODORE MICROCOMPUTERS MAGAZINE
September/October, 1986.
**************************************
NOTE: Because this program is written
for the Commodore 128, it cannot be
run like other programs on LOADSTAR.
To run this program, press your 128's
RESET button. This will display a
menu of all C-128 programs on this
issue. Choose the program you want to
run from this menu.
**************************************
The MAGIC LANTERN demonstrates an
animation technique that takes
advantage of the 128's ability to
store several hi-res pictures in
memory.
When you run MAGIC LANTERN, the
program draws a sequence of hi-res
pictures of a cartoon factory and
stores them in memory. Like
individual frames of a movie, each
picture differs from the next only
slightly. When the program flashes
the drawings on the screen one after
the other, the factory appears to be
running.
How does the program work? A
machine-language subroutine located in
the cassette buffer transfers blocks
of memory from the storage locations
to the bitmap display area of memory.
If you are skilled enough to produce
your own hi-res pictures, you can use
MAGIC LANTERN's routines to create
your own animations.
NUTS AND BOLTS
--------------
Because the program's author needed
to store eight high-res pictures, he
found he did not have enough room in
Bank 1 for both the program and eight
full-screen pictures. Thus he decided
to have the "frames" of the animation
be a little under half of a screen in
size. He used the hi-res, split-
screen mode called by the command
GRAPHIC 2,1,13.
If you intend to use the MAGIC
LANTERN routines in your own programs,
the author has additional information
about the following lines:
LINE 3910: The variable NP is set
equal to the number of pages in memory
that you wish to save and swap. The
author saved 17 pages. Saving the
full bitmap, for example, would take
32 pages; the full bitmap with color
memory would need 36 pages. The value
of NP is poked into memory where the
machine-language routine can refer to
it by line 3920.
LINE 3970: SF ("starts from") is the
decimal value of the high byte that
your save/swap is to start from; the
low high byte is always zero. To
start from color memory, set SF=28.
For just the bitmap, set SF=32. You
can start your cartoon at the top of
the screen-- just set the value of SF
accordingly.
The machine-language routine is
called with a SYS 2816, followed by
two parameters. The first value is
the number of the picture you want to
display. The second is either zero or
one. If the machine-language sees
that your second parameter is zero, it
will transfer the portion of memory at
the bitmap (or wherever else you told
it through variable SF) to an area
above the BASIC program. This is
used to save a picture for later
display.
If, on the other hand, the routine
finds a value of one for the second
parameter, it will transfer the
picture from memory into the bitmap
area.
One more note: be careful that your
BASIC program doesn't "grow up" into
the area where you store your
pictures.
A NOTE ABOUT MAGIC LANTERN
--------------------------
If you want to see the animation
without watching the pictures drawn
each time, there is a small program,
QUICK DEMO, that will save the
machine-language routine and all of
the graphic pictures to disk.
To use this program, you need a disk
with at least 140 blocks free (one of
your own, not LOADSTAR!). After
stopping MAGIC LANTERN, insert the
disk with at least 140 free blocks
into your drive and type RUN 4210.
This BSAVES the two areas of memory.
After you have saved everything,
running QUICK DEMO, which BLOADS the
pictures and routine from the disk,
will start the factory up again.
DISK FILES THIS PROGRAM USES:
MAGIC LANTERN QUICK DEMO
-----------< end of text >------------